/*
 * Sink.scala
 */

package acorn.jash.io

import acorn.jash.{Input,Output,Path}

import scala.collection.mutable.ListBuffer

class Sink extends Input with Output {

  override def get():String = if (li isEmpty) null
                              else {
                                val cont = li toList
                                var rt = new StringBuilder
                                cont.foreach{rt append _}
                                li.clear; rt.toString
                              }

  override def put(arg:String) {li += arg}

  override def putln(arg:String) {li += (arg + Path.lineSeparator)}

  val li = new ListBuffer[String]
}
